package com.bawei.module_detail.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import java.util.ArrayList

class TabAdapter : FragmentPagerAdapter {
    var list: List<Fragment> = ArrayList()
    var data: List<String> = ArrayList()

    constructor(fm: FragmentManager, list: List<Fragment>, data: List<String>) : super(fm) {
        this.list = list
        this.data = data
    }

    constructor(fm: FragmentManager, list: List<Fragment>) : super(fm) {
        this.list = list
    }

    constructor(
        fm: FragmentManager,
        behavior: Int,
        list: List<Fragment>,
        data: List<String>
    ) : super(fm, behavior) {
        this.list = list
        this.data = data
    }

    override fun getItem(position: Int): Fragment {
        return list[position]
    }

    override fun getCount(): Int {
        return list.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return data[position]
    }
}
